Repository navigation
Reject unknown preset text that injects PPD lines (OCU-01-008) - #105
Open
Dhirenderchoudhary wants to merge 2 commits into
Open
Dhirenderchoudhary wants to merge 2 commits into
Dhirenderchoudhary wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
7ASecurity audit of OpenPrinting, finding OCU-01-008, WP1/2, Medium.
CUPS and libppd build a local PPD from the IPP attributes of a remote printer when a driverless queue is created. Known
job-presets-supportedmembers are mapped to PPD keywords. Unknown members were written withippAttributeString()andcupsFilePrintf(fp, "*%s %s\n", member_name, member_value).ippAttributeString()keeps embedded newlines in text and name values, so a preset value can start a new top-level PPD statement such as*cupsFilter2.A printer on the network can advertise that collection in Get-Printer-Attributes. If someone adds the printer with a driverless path such as
lpadmin -m everywhere, the queue PPD can contain those extra statements. Later print jobs then follow the injected PPD, not only the options the printer meant to describe. Remote capability data is supposed to describe device options. It is not supposed to author top-level PPD directives.Why
The fallback treated an unknown preset member as safe PPD syntax. The fix writes an unknown member only when the value is a boolean, an integer, or a keyword, and
ippValidateAttribute()accepts the member. That is the same gate the CUPS generator already uses.What changed
test_ppd_generatorbuilds a preset withsides=one-sided, aprint-color-modekeyword, and a text value that contains a newline. The generated file must contain*Duplex Noneand*print-color-mode monochrome, and must not contain the injected directive.Scope
This pull request covers the libppd generator. A separate pull request covers the CUPS copy.
ippAttributeString()is unchanged. foomatic-rip is unchanged.Tradeoffs
Dropping every unknown member would also drop real keyword options such as
print-color-mode. The generator keeps boolean, integer, and keyword members.Blast Radius
Driverless PPDs no longer copy text or name preset members. Presets that only use boolean, integer, and keyword members still appear.
Verification
test_ppd_generatorprintedpreset text newline is not a new PPD directive: FAIL (duplex=1 color=1 injected=1)and exited 1.PASS (duplex=1 color=1 injected=0)and exited 0. The rest oftest_ppd_generatorpassed (50 PASS lines, exit 0).